/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2018-2021.
 * Description: add exception prehandler support
 * Author: liujianping <jianping.liu@huawei.com>
 * Create: 2018-09-28
 */

#ifndef __SYSTEM_MISC_RTOS_H
#define __SYSTEM_MISC_RTOS_H

#include <linux/compiler.h>
#include <linux/linkage.h>
#include <linux/irqflags.h>
#include <linux/reboot.h>

#ifdef CONFIG_RTOS_HAL_SRE_PREHANDLER
#define EXCEPT_TYPE_UND         0
#define EXCEPT_TYPE_PABT        1
#define EXCEPT_TYPE_DABT        2
#define EXCEPT_TYPE_NR          3

#define SRE_UEXCEPT_CAN_HANDLE  0
#define SRE_UEXCEPT_BYPASS      -1
struct usr_except_args {
	unsigned int except_type;
	unsigned long addr;
	unsigned int fsr;
	struct pt_regs *sp;
};

int sre_prehandler_unregister(struct task_struct *task);
int sre_prehandler_register(struct task_struct *task, int (*handler)(struct usr_except_args *args));

extern char *except_desc_array[EXCEPT_TYPE_NR + 1];
#endif	/* CONFIG_RTOS_HAL_SRE_PREHANDLER */

#endif
